    function getCookie(name) {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(
                            cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    };
    function GetRequest(){
        rnode = document.getElementById('raw')
        //alert(rnode.toString())

        inodes = document.getElementsByTagName("textarea")
        var data = '{'
        for (var i= 0;i<inodes.length;i++){
            inode = inodes[i]
            //alert(inode.toString)
            key = inode.getAttribute('name')

            value = inode.value
            //alert(key+':'+value)
            if (i==0){
                //data = data + '"'+key+'":"'+value+'"'
                data = data +key+':"'+value+'"'
            } else{
                //data = data + ',"'+key+'":"'+value+'"'
                data = data + ','+key+':"'+value+'"'
            }

        }
        data = data +'}'

        return eval("(" + data + ")")
    };

    function request_history(){
        var csrftoken = getCookie('csrftoken');
        request = GetRequest();
        request['csrfmiddlewaretoken'] = csrftoken
        //alert('start')
        
        $.ajax({
            type: "POST",
            //url: "./",

            data: request,
            dataType: "json",
            success: function(data) {
                data = JSON.stringify(data)
                //alert(data);
                show_result(data);
            }
        });
    }

    function show_result(data){
        //$( "#api_result").value = data
        rnode = document.getElementById('api_result');
        rnode.value = data;
    }